package com.mall4j.cloud.product.controller.app;

import io.swagger.annotations.Api;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController("testController")
@RequestMapping("/ua/test")
@Api(tags = "app-test")
public class TestController {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @GetMapping("sendMq")
    public Object sendMq() {
        System.out.println(new Date());
        SendResult sendResult = rocketMQTemplate.syncSendDelayTimeSeconds("mall-topic", "hello msg", 15);
        System.out.println(new Date());
        return sendResult;
    }

}
